%Cuantificacion no uniforme
%%Ley u
x = -1:.01:1;
Fx = zeros(1,numel(x));
mu = 255;
for i=1:numel(x)
    if x(i)<0
        Fx(i) = (-1)*((log(1+(mu* x(i))))/(log(1+mu)) );
    end
    if x(i)==0
        Fx(i) = (0)*((log(1+(mu* x(i))))/(log(1+mu)) );
    end
    if x(i)>0
        Fx(i) = (1)*((log(1+(mu* x(i))))/(log(1+mu)) );
    end
end
plot(x,Fx)
%% Ley A
Fx = zeros(1,numel(x));
A = 87.7;
for i=1:numel(x)
    if (abs(x(i)) < (1/A))
        
        if x(i)<0
            Yx(i) = -1*(A*abs(x(i)))/(1+log(A));
        end
        if x(i)==0
            Yx(i) = 0;
        end
        if x(i)>0
            Yx(i) = (1*A*abs(x(i)))/(1+log(A));
        end
    end
    if (1/A <= abs(x(i)))
        
        if x(i)<0
            Yx(i) = -1*(1+log(A*abs(x(i))))/(1+log(A));
        end
        if x(i)==0
            Yx(i) = 0;
        end
        if x(i)>0
            Yx(i) = 1*(1+log(A*abs(x(i))))/(1+log(A));
        end
    end
end
figure;
plot(x,Yx)